
var express = require('express');
var router  = express.Router();
var fs = require('fs'); 
var gm = require('gm');
var imageMagick = gm.subClass({ imageMagick: true });

router.get('/', function(req, res) {
	var font = req.query.font;
	var msg = req.query.msg;
	var x = req.query.x;
	var y = req.query.y;
	imageMagick('/Users/mlv/Documents/workspace/corstone/img/img/bc0.png')    
        .font('/Users/mlv/Documents/workspace/corstone/img/font/.TTF')
        .fontSize(50)
        .draw('text  '+x+','+y+' '+msg)

        .toBuffer( function(err,buffer) {        
              if (!err){  
              	res.writeHead('200', {'Content-Type': 'image/jpeg'});    
         				res.end(buffer,'binary');          
         }else{console.log(err.message || ""); } });
              	
});

module.exports = router;
